// register-step02
let opsd2 = document.querySelector("#psd2")
let orestip = document.querySelector(".restip");
let obtn3 = document.querySelector(".btn3");

// 密码框样式
opsd2.addEventListener("focus",() => {
    opsd2.style.boxShadow = " 1px 1px 1px #2c82ff, -1px -1px 1px #2c82ff";
})
opsd2.addEventListener("blur",() => {
    opsd2.style.boxShadow = "none";
})

// 点击下一步
obtn3.addEventListener("click",function(){
    if(opsd2.value === localStorage.getItem("password01")){
        ajax({
            type:"post",
            url:"http://localhost:3000/register",
            data:{
                type:"register",
                username:localStorage.getItem("username"),
                password:opsd2.value,
            },
            success:(res) => {
                console.log(res);
                res = JSON.parse(res);
                if (res.code === 0) {
                    orestip.innerHTML = "注册失败,用户名重复";
                } else if(res.code === 1){
                    location.href = "./register-step03.html"
                }
            },
        })
        
    }else{
        orestip.innerHTML = "密码输入错误，请重新输入"
    }
})